//
//  PagedControlStyle.swift
//  Alamofire
//
//  Created by Fanxx on 2019/7/8.
//

import UIKit

extension UCSetting where TargetType: UIPageControl {
    ///背景点颜色
    public static func color(_ color:UIColor?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.pageIndicatorTintColor = color
        })
    }
    ///选中点颜色
    public static func current(color:UIColor?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.currentPageIndicatorTintColor = color
        })
    }
    ///单页隐藏
    public static func autoHide(_ hides: Bool = true) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.hidesForSinglePage = hides
        })
    }
    ///页数
    public static func pages(_ count: Int) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.numberOfPages = count
        })
    }
    ///当前页码
    public static func current(_ current: Int) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.currentPage = current
        })
    }
    ///backgroundStyle
    @available(iOS 14.0, *)
    public static func bg(style: UIPageControl.BackgroundStyle) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.backgroundStyle = style
        })
    }
    ///allowsContinuousInteraction
    @available(iOS 14.0, *)
    public static func continuous(interaction allow: Bool) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.allowsContinuousInteraction = allow
        })
    }
    ///preferredIndicatorImage
    @available(iOS 14.0, *)
    public static func image(preferred image:UIImage?) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.preferredIndicatorImage = image
        })
    }
    ///setIndicatorImage(_ image: UIImage?, forPage page: Int)
    @available(iOS 14.0, *)
    public static func image(_ image:UIImage?, for page: Int) -> UCSetting<TargetType> {
        return .init(action: { (target) in
            target.setIndicatorImage(image, forPage: page)
        })
    }
}

